﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace Rsa.Controllers {
    
    [Authorize(Roles="usuario")]
    public class UsuarioController : Controller {

        private ActionResult CerrarSesion() {
            FormsAuthentication.SignOut();
            return RedirectToAction("Index", "Inicio");
        }

        public ActionResult Index() {
            // Verifica que la variable de sesion del usuario exista,
            // caso contrario cierra sesion
            if(Session["Rsa_Usuario"] == null) {
                return CerrarSesion();
            }

            return View();
        }

        public ActionResult LogOut() {
            return CerrarSesion();
        }
    }
}
